/******
 * waitpid.c - Simple wait usage
 *********/
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>

struct bitop
{
  unsigned fstbit :1;
  unsigned secbit :1;
  unsigned thdbit :1;

  char a;
  char b;
  char c;
};

struct mega
{
  struct mega *next;
  char dummy[1 << 20 - 4];
};

int FreeMem(void);

int main(void)
{
  struct bitop bstruct;
  bstruct.fstbit = 0;
  bstruct.secbit = 1;
  bstruct.thdbit = 0;

  int sum = 10;

  printf(" sizeof bitop = %d\n", sizeof(bstruct));
  printf(" bstruct.fstbit = %d  sizeof() = %d\n", bstruct.fstbit);
  printf(" bstruct.secbit = %d\n", bstruct.secbit);
  printf(" bstruct.thdbit = %d\n", bstruct.thdbit);

  printf(" int sum +  bstruct.secbit = %d\n", sum + bstruct.secbit);

  return 0;
}

int FreeMem(void)
{
  long counter;
  struct mega *head, *current, *nextone;

  current = head = (struct mega*) malloc(sizeof(struct mega));

  if (head == NULL )
  {
    return 0;
  }

  counter = 0;
  do
  {
    counter++;
    current->next = (struct mega*) malloc(sizeof(struct mega));
    current = current->next;
    printf("\r%d", counter);
  } while (current != NULL );

  current = head;
  do
  {
    nextone = current->next;
    free(current);
    current = nextone;
  } while (nextone != NULL );

  return counter;
}
